﻿using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;


public class HandlerManager : MonoBehaviour
{
    public IDictionary<int, MethodInfo> methodMap = new Dictionary<int, MethodInfo>();
    void Start()
    {
        Assembly asm = Assembly.GetExecutingAssembly();
        Module[] modules = asm.GetModules();
        Type[] types = modules[0].FindTypes((type, obj) => true, null);
        foreach (Type type in types)
        {
            MethodInfo[] methods = type.GetMethods();

            foreach (MethodInfo method in methods)
            {
                Attribute[] atts = Attribute.GetCustomAttributes(method);
                foreach (Attribute attr in atts)
                {
                    if (attr.GetType() == typeof(Opcode))
                    {

                        methodMap[(attr as Opcode).Id] = method;
                        break;
                    }
                }
            }

        }
    }

    // Update is called once per frame
    void Update()
    {

    }
    void OnDestroy()
    {

    }





}

